/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package proxyserverapp;


import java.rmi.Naming;
import java.util.Scanner;

/*
 * Esta eh a classe cliente que ficara acessando o proxy e requisitando contas
 */
public class CalculadoraClient {

	public static void main(String args[]) {

            try {
                Scanner sc = new Scanner(System.in);

                System.out.print("Digite o IP do servidor de proxy: ");
                String serverip = sc.nextLine();

                IProxy c = (IProxy) Naming.lookup("rmi://" + serverip + ":1099/ProxyService1");

                String answer;
                do {
                    System.out.println("Write 'Bye' to exit...");
                    System.out.print("X: ");
                    answer = sc.nextLine();
                    int x = Integer.parseInt(answer);
                    System.out.print("Y: ");
                    answer = sc.nextLine();
                    int y = Integer.parseInt(answer);
                    int finalanswer = c.add(x,y);
                    System.out.println("Calculadora service says: " + finalanswer);
                } while(answer.compareToIgnoreCase("Bye") != 0);

            } catch (Exception e) {
                    System.out.println(e);
            }
	}
}


